/**
 * 适用于NodeJS支持的Buffer的实现类
 */
var createNodeBuffer = (function () {
    if ('allocUnsafe' in Buffer) {
        return function (data) {
            res = Buffer.allocUnsafe(data);
            return  res;
        }
    } else {
        return function (data) {
            return new Buffer(data);
        }
    }
}());

var nodebuffer = createNodeBuffer(8);
nodebuffer.writeUInt8(100,0);
nodebuffer.writeUInt16BE(65535,1);
console.log("nodebuffer is",nodebuffer)